<?php
namespace app\admin\model;

use think\Model;
use think\facade\Config;
class Enquire extends Model
{   
	 protected $connection = 'publicdata';
	/*查询数据 */
	public function get_data($page,$limit){
		/*搜索条件*/
		/*$req=request()->param();
		if(!empty($req['start_time'])||!empty($req['end_time'])){ 
			if(!empty($req['start_time'])){
        		$sear_where[]=['create_time','>=',$req['start_time']." 00:00:00"];
        	}
        	if(!empty($req['end_time'])){
        		$sear_where[]=['create_time','<',$req['end_time']." 23:59:59"];
        	}
        	$list=Enquire::where($sear_where)
			->where([['status','=',1]])
            ->order('id','desc')
            ->paginate(Config::get('app.admin_page_number'),false,['query' => $req]);
            $data['list']=$list;
		}else{
			
			$list=Enquire::where([['status','=',1]])->order('id', 'desc')->select()->toArray();
            $data['list']=$list;
		}*/

	    $start=($page-1)*$limit;
		$list=Enquire::where([['status','=',1]])->order('id', 'desc')->limit($start,$limit)->select()->toArray();
		$data['count']=Enquire::count();
        $data['list']=$list;

        return $data;
		
	}
	
	/*删除假动作实际为修改操作*/
	public function delete_data($id){
        $data = Enquire::get($id);
        if($data['status']!=1){
        	$result=['status'=>'0','msg'=>'无需操作'];
	        return json($result);
        }
		$data->status = '2';
		$result=$data->save();
		return $result;
	}

	/*查询一条*/
	public function get_one_data($id){
        $data = Enquire::get($id);
        
		return $data;
	}
}
 